package com.zufangbao.earth.task;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.zufangbao.earth.handler.RentNotifyHandler;

@Component
public class RentNotifyTask {

	@Autowired
	private RentNotifyHandler rentNotifyHandler;
	
	private static Log logger = LogFactory.getLog(RentNotifyTask.class);
	
	/**
	 * 每天上午12点开始付租提醒
	 */
	@Scheduled(cron = "0 0 12 * * ?")
	public void rentNotify(){
		
		logger.info("begin to notify renter");
		 
		 try {
			 
			 rentNotifyHandler.sendSms4NotifyPayRent(new Date());
			 
			 logger.info("end to notify renter");
			
		}  catch (Exception e) {
			
			e.printStackTrace();
			
			logger.error("notify renter occur error with errorCode[" +e.getMessage() + "]");
		}
		 
	 }
}
